package com.fulin.leetcode;

import java.util.*;

/**
 * TODO
 *
 * @Author fulin
 * @Date 2022/9/13 18:52
 **/
public class Num22 {

    public static void main(String[] args) {
        List<String> result = new ArrayList<>();
        gen("",3,3,result);
        System.out.println(result.toString());
    }

    public static void gen(String str,int left,int right,List<String> result) {
        if(left == 0 && right == 0){
            result.add(str);
            return;
        }

        if(right < left){
            return;
        }

        if(left >= 1){
            gen(str + "(",left - 1,right,result);
        }
        if(right >= 1){
            gen(str + ")",left,right - 1,result);
        }
    }

}
